package com.amado.course39match;

import java.math.BigDecimal;

/**
 * 用于操作浮点型数据，加减乘除幂
 * Created by Administrator on 2018/8/4.
 */
public class BigDecimalFloatTest {
    public static void main(String[] args) {
        System.out.println(new BigDecimal(Float.toString(125.123f)).toString());
        System.out.println(new BigDecimal(125.123f));
//        其值为 (unscaledVal × 10-scale) 的 BigDecimal。


        // 1*10的负1次幂 = 1* 0.1=0.1
        System.out.println(BigDecimal.valueOf(1,1));
        // 2*10的负2次幂 = 2* 0.01=0.02
        System.out.println(BigDecimal.valueOf(2,2));
        // 3*10的负3次幂 = 3* 0.001=0.003
        System.out.println(BigDecimal.valueOf(3,3));

        // 1*10的1次幂 = 1* 10=0.1
        System.out.println(BigDecimal.valueOf(1,-1).toPlainString());
        // 2*10的2次幂 = 2* 100=0.02
        System.out.println(BigDecimal.valueOf(2,-2).toPlainString());
        // 3*10的3次幂 = 3* 1000=0.003
        System.out.println(BigDecimal.valueOf(3,-3).toPlainString());
        System.out.println(BigDecimal.valueOf(13,1).toPlainString());

    }

}
